//
// winter - Direct2D GUI framework.
// Copyright (C) 2009 Aleksandar Dezelin 
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

#ifndef APPLICATION_HOST_H
#define APPLICATION_HOST_H

#pragma once
#include "winter_assert.h"
#include <Windows.h>

// In-memory .EXE file header
extern "C" IMAGE_DOS_HEADER __ImageBase;

namespace winter {
namespace platform {

///
/// <summary>
///     Platform specific stuff.
/// </summary>
///
class application_host {
public:
  application_host() {
    _thread_id = ::GetCurrentThreadId();
  }

  ///
  /// <summary>
  ///     Returns application instance handle.
  /// </summary>
  /// <returns>
  ///     Instance handle.
  /// </returns>
  ///
  HINSTANCE get_instance() const {
    return reinterpret_cast<HINSTANCE>(&__ImageBase);
  }

  ///
  /// <summary>
  ///     Returns the id of the thread which created the application_host 
  ///     instance.
  /// </summary>
  /// <returns>
  ///     Thread id.
  /// </returns>
  int get_thread_id() const {
    return _thread_id;
  }

private:
  int _thread_id;
};

}
}

#endif // APPLICATION_HOST_H
